package com.yyfax.ph.common.utils;

import android.os.Handler;
import com.yyfax.ph.BuildConfig;

import java.util.HashMap;
import java.util.Map;

public class Constants {

	/**
	 * 账号类型 1.子账号; 2.母账号
	 */
	public final static int TYPE_SUB_ACCOUNT = 1;
	public final static int TYPE_MOTHER_ACCOUNT = 2;

	public static final String BANK_CODE_ICBC = "000001"; // 中国工商银行
	public static final String BANK_CODE_ABC = "000002"; // 中国农业银行
	public static final String BANK_CODE_BOC = "000003"; // 中国银行
	public static final String BANK_CODE_CCB = "000004"; // 中国建设银行
	public static final String BANK_CODE_CITIC = "000005"; // 中信银行
	public static final String BANK_CODE_CEB = "000006"; // 中国光大银行
	public static final String BANK_CODE_HXB = "000007"; // 华夏银行
	public static final String BANK_CODE_GDB = "000008"; // 广发银行
	public static final String BANK_CODE_PINGAN = "000009"; // 平安银行
	public static final String BANK_CODE_CMB = "000010"; // 招商银行
	public static final String BANK_CODE_CIB = "000011"; // 兴业银行
	public static final String BANK_CODE_SPDB = "000012"; // 中国浦东发展银行
	public static final String BANK_CODE_PSBC = "000013"; // 中国邮政储蓄银行
	public static final String BANK_CODE_CMBC = "000014"; // 中国民生银行
	public static final String BANK_CODE_BEIJING = "000015"; // 中国北京银行

	/**
	 * 保存客户经理编号
	 */
	public final static String CUSTOMER_MANAGER = "customerManager";

	public final static int MAX_IMAGE_COUNT_DEFAULT = 50;

	/**
	 * 图像类型 00:征信图片，01:手持身份证照片，02:身份证正面照片，03:身份证反面照片，04:查询授权书照片，05:查阅授权书照片，06:房产贷证明材料，07:身份证证件照片
	 */

	/**
	 * 上传图片类型--征信图片 00
	 */
	public final static String IMAGE_TYPE_CREDIT = "00";
	/**
	 * 上传图片类型--人像照片 01
	 */
	public final static String IMAGE_TYPE_PORTRAIT = "01";
	/**
	 * 上传图片类型--身份证正面照片 02
	 */
	public final static String IMAGE_TYPE_ID_CARD_FRONT = "02";
	/**
	 * 上传图片类型--身份证反面照片 03
	 */
	public final static String IMAGE_TYPE_ID_CARD_BACK = "03";
	/**
	 * 上传图片类型--查询授权书照片 04
	 */
	public final static String IMAGE_TYPE_QUERY_AUTHORIZE = "04";
	/**
	 * 上传图片类型--查阅授权书照片 05
	 */
	public final static String IMAGE_TYPE_QUERY_APPLY = "05";
	/**
	 * 上传图片类型--房产贷证明材料 06
	 */
	public final static String IMAGE_TYPE_HOUSE_LOAN = "06";
	/**
	 * 上传图片类型--身份证证件照片 07
	 */
	public final static String IMAGE_TYPE_ID_CARD_HEAD = "07";

	public final static int BUSINESS_NO_CREDIT = 0;
	public final static int BUSINESS_HAS_CREDIT = 1;
	public final static int BUSINESS_NO_CREDIT_REUPLOAD = 2;
	//2：专业推荐
	public final static String RECOMMEND_HAS_CREDIT = "2";
	//3：征信授权
	public final static String RECOMMEND_NO_CREDIT = "3";
	/**
	 * 方案类型：房产贷(唯一产权人)
	 */
	public final static String BUSINESS_TYPE_HOUSE_UNIQUE = "210";
	/**
	 * 方案类型：房产贷(共有产权人)
	 */
	public final static String BUSINESS_TYPE_HOUSE_SHARE = "220";
	/**
	 * 方案类型：公务员客户
	 */
	public final static String BUSINESS_TYPE_CIVIL_SERVICE = "260";
	/**
	 * 搜索状态 0:全部状态 1：审批中 2：已退回 3：待面签 4：已完成 6：待借钱 7：待处理 8：已放款 9：已否决
	 */
	public final static String PROGRESS_STATUS_ALL = "0";
	public final static String PROGRESS_STATUS_WAITE_DEAL = "7";
	public final static String PROGRESS_STATUS_APPROVAL = "1";
	public final static String PROGRESS_STATUS_CONTRACT = "8";
	public final static String PROGRESS_STATUS_REJECT = "9";
	/**
	 * 进度查询状态样式 1:正常 2:待办 3:置灰
	 */
	public final static String PROGRESS_NORMAL = "1";
	public final static String PROGRESS_WAIT_TO_DEAL_WITH = "2";
	public final static String PROGRESS_DISABLE = "3";

	/**
	 * 进度查询头像 1:男头像 2:女头像 3:云贷头像
	 */
	public final static String PROGRESS_ICON_MAN = "1";
	public final static String PROGRESS_ICON_WOMAN = "2";
	public final static String PROGRESS_ICON_LOGO = "3";
	/**
	 * 是否试算额度 0: 未试算 1：已试算 2：无需试算
	 */
	public final static String COUNT_HAS_NOT_BEEN_CALCULATED = "0";
	public final static String COUNT_HAS_BEEN_CALCULATED = "1";
	public final static String COUNT_NOT_NEED_TO_CALCULATE = "2";
	/**
	 * 节点样式（1：中间节点 2：最后节点（未结束） 3：最后节点（已结束））
	 */
	public final static String PROGRESS_HISTORY_INTERMEDIATE_NODE= "1";
	public final static String PROGRESS_HISTORY_LAST_NODE_NOT_OVER = "2";
	public final static String PROGRESS_HISTORY_LAST_NODE_OVER = "3";
	/**
	 * supplementType补件样式（0：不需要补件 1：补充征信报告 2：补充征信授权）
	 */
	public final static String NO_NEED_SUPPLEMENT = "0";
	public final static String NEED_SUPPLEMENT_CREDIT = "1";
	public final static String NEED_SUPPLEMENT_CREDIT_QUERY_AUTH = "2";

	/**
	 * creditType征信类型（0：不可查看征信 1：可查看有通道征信 2：可查看无通道征信）
	 */
	public final static String DO_NOT_CHECK_CREDIT = "0";
	public final static String CHANNEL_CREDIT = "1";
	public final static String NO_CHANNEL_CREDIT = "2";
	/**
	 * rcmdType推荐类型（1：云测推荐 2：云贷推荐）
	 */
	public final static String RECOMMEND_FROM_CMA = "1";
	public final static String RECOMMEND_FROM_LAS = "2";


	/** 7.0以上系统访问私有目录的权限.*/
	public static final String FILE_PROVIDER_AUTHORITY = "com.yyfax.ph.fileprovider";

	//选项卡类型
	public final static String OPTION_BUSINESS_TYPE = "business_type";//业务类型
	public final static String OPTION_OFFICIAL_LEVEL = "official_type";//公务员级别
	public final static String OPTION_MARRIAGE = "marriage_type";//婚姻状态
	public final static String OPTION_EDUCATION_LEVEL = "education_type";//教育程度
	public final static String OPTION_LIVING_CONDITION = "living_type";//居住状态
	public final static String OPTION_RELATIONSHIP = "relationship_type";//与本人关系

	public static boolean IS_DEBUG = BuildConfig.DEBUG;

	public static String REMOTE_URL;

	/**ShareSDK~~start*/
	/**
	 * 在ShareSDK注册的应用所对应的app key
	 */
	public static String SHARE_SDK_KEY;
	/**
	 * 微信好友+朋友圈
	 */
	public static String WE_CHAT_APP_ID = "wx6350095938b49eba";
	public static String WE_CHAT_SECRET = "b40b31b8014822f23152bcb76516b8b7";
	public static final String WE_CHAT_ENABLE = "true";
	public static final String WE_CHAT_BYPASS_APPROVAL = "false";
	/**
	 * 新浪微博
	 */
	public static final String WEI_BO_APP_KEY = "1734091440";
	public static final String WEI_BO_APP_SECRET = "c4626e708fd1d7630382ac7fbd596976";
	public static final String WEI_BO_REDIRECT_URL = "https://api.weibo.com/oauth2/default.html";
	public static final String WEI_BO_ENABLE = "true";
	public static final String WEI_BO_SHARE_BY_APP_CLIENT = "false";
	/**
	 * 腾讯开放平台
	 */
	public static final String QQ_ID = "3";
	public static final String QQ_SORT_ID = "3";
	public static final String QQ_APP_ID = "1104934848";
	public static final String QQ_APP_KEY = "eusC2Si3StrQV4HD";
	public static final String QQ_SHARE_BY_APP_CLIENT = "true";
	public static final String QQ_ENABLE = "true";
	public static final String QQ_FRIEND_ID = "7";
	public static final String QQ_FRIEND_SORT_ID = "7";
	/**ShareSDK~~end*/

	/**
	 * 推荐贷款
	 */
	public static final String WORK_TYPE_BUSINESS_OWNER = "010"; // 企业主
	public static final String WORK_TYPE_OFFICE_WORKER = "020"; // 上班族
	public static final String NO_NATIVE_HOUSE = "0"; // 无本地房产
	public static final String HAS_NATIVE_HOUSE = "1"; // 无本地房产


	/**
	 * 验证码有效时长（秒）
	 */
	public static final int TIME = 60;
	/**
	 * 当前时间
	 */
	private static Map<String, Integer> mCURRENT_TIME_MAP = new HashMap<>();

	public static abstract class TimerTask {
		public abstract void onEnd();

		public abstract void onTime(int time);

		public abstract String getKey();
	}

	public static TimerTask timerTask;

	public static void startTimer(final String key) {
		final Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			int currentTime = 0;

			@Override
			public void run() {
				currentTime++;
				if (currentTime == Constants.TIME) {
					if (timerTask != null) {
						String cName = timerTask.getKey();
						if (cName.equals(key)) {
							timerTask.onEnd();
							timerTask = null;
						}
					}
					handler.removeCallbacks(this);
					mCURRENT_TIME_MAP.remove(key);
				} else {
					handler.postDelayed(this, 1000);
					if (timerTask != null) {
						String cKey = timerTask.getKey();
						if (cKey.equals(key))
							timerTask.onTime(currentTime);
					} else {
						currentTime = 0;
						handler.removeCallbacks(this);
					}
					mCURRENT_TIME_MAP.put(key, currentTime);
				}
			}
		}, 1000);
	}

	public static int getCurrentTime(String clazzName) {
		if (mCURRENT_TIME_MAP.size() == 0 || !mCURRENT_TIME_MAP.containsKey(clazzName))
			return -1;
		return mCURRENT_TIME_MAP.get(clazzName);
	}
}
